#include <iostream>
#include <stack>
#include <queue>
#include <iomanip>
//#include <windows.h>
using namespace std;

int main()
{
    stack<string> positive;
    queue<string> negative;
    string a;
    while (cin >> a)
    {
        if (a.substr(0,1) != "-")
        {
            positive.push(a);
        }
        else
        {
            negative.push(a);
        }
    }
    while (!positive.empty())
    {
        cout << setw(5) << positive.top().substr(0, 5);
        positive.pop();
    }
    cout << endl;
    while (!negative.empty())
    {
        cout << setw(5) << negative.front().substr(0,5);
        negative.pop();
    }
    cout << endl;
    //system("pause");
    return 0;
}